package com.onpositive.datamap.values.impl;

import com.onpositive.datamap.IDataPropertyValue;
import com.onpositive.datamap.core.IDataProperty;

public abstract class BasicValue implements IDataPropertyValue{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	protected IDataProperty prop;
	
	protected Object comment;
	
	protected BasicValue(){
		
	}
	
	public BasicValue(IDataProperty prop, Object comment) {
		super();
		this.prop = prop;
		this.comment = comment;
	}

	@Override
	public IDataProperty getProperty() {
		return prop;
	}

	@Override
	public Object getComment() {
		return comment;
	}

	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((comment == null) ? 0 : comment.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		BasicValue other = (BasicValue) obj;
		if (comment == null) {
			if (other.comment != null)
				return false;
		} else if (!comment.equals(other.comment))
			return false;
		if (!this.getProperty().getId().equals(other.getProperty().getId())){
			return false;
		}
		return true;
	}

	public BasicValue toTransferForm() {
		this.prop=null;
		return this;
	}

	
	

}
